Ext.onReady(function(){

    Ext.application({
		requires: ['Ext.container.Viewport'],
		name: 'AM',

		appFolder: 'app',

		launch: function() {
			Ext.create('Ext.container.Viewport', {
				layout: 'fit',
				items: [
					{
						xtype: 'panel',
						title: 'Users',
						html : 'List of users will go here'
					}
				]
			});
		}
	});

	Ext.define('AM.controller.Users', {
		extend: 'Ext.app.Controller',

		init: function() {
			this.control({
				'viewport > panel': {
					render: this.onPanelRendered
				}
			});
		},

		onPanelRendered: function() {
			console.log('The panel was rendered');
		}
	});

	Ext.define('AM.view.user.List' ,{
		extend: 'Ext.grid.Panel',
		alias: 'widget.userlist',

		title: 'All Users',

		initComponent: function() {
			this.store = {
				fields: ['name', 'email'],
				data  : [
					{name: 'Ed',    email: 'ed@sencha.com'},
					{name: 'Tommy', email: 'tommy@sencha.com'}
				]
			};

			this.columns = [
				{header: 'Name',  dataIndex: 'name',  flex: 1},
				{header: 'Email', dataIndex: 'email', flex: 1}
			];

			this.callParent(arguments);
		}
	});
	
}); //end onReady